package com.wsjzzcbq.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import java.awt.*;
import java.io.IOException;

/**
 * FontUtils
 *
 * @author wsjz
 * @date 2023/11/01
 */
@Slf4j
public class FontUtils {

    public static Font font() {
        ClassPathResource resource = new ClassPathResource("font/simsun.ttc");
        try {
            Font font = Font.createFont(Font.TRUETYPE_FONT, resource.getInputStream());
            return font.deriveFont(Font.BOLD, 17);
        } catch (FontFormatException | IOException e) {
            log.error(e.getMessage(), e);
            return new Font("宋体", Font.BOLD, 17);
        }
    }
}
